LearningStoreQuery Class

Represents a query that can be used to retrieve information from the database.

Namespace: Microsoft.LearningComponents.Storage

Assembly: Microsoft.LearningComponents.Storage.dll

Syntax
C#

public class LearningStoreQuery

Methods
Name Description
Ð AddColumn

Add a new output column in the result.

Ð AddCondition

Add a condition that restricts the data returned in a query.

Ð AddSort

Add a sort order for the returned data

Ð SetParameter

Sets the value for a parameter in a query.

Remarks

Steps required to perform a query on a store:

  1. Create a LearningStoreQuery object on the store using LearningStore.CreateQuery.
  2. Call methods on the LearningStoreQuery to finish defining the query. Add parameter values, output columns, conditions, and/or sorting information.
  3. Call LearningStoreJob.PerformQuery to add the "perform query" operation to a job on the store.
  4. Execute the job. A System.Data.DataTable is returned as a result. See the LearningStoreJob.PerformQuery documentation for more information about the results returned.

The definition of an query includes:

Here's a very simple query:
C#
LearningStoreQuery query = store.CreateQuery("UserItem");
query.AddColumn("Name");
The query above will return the names of all the users in the store. The output DataTable will contain one row for each UserItem. The output DataTable will contain one column named "Name." That column will contain the value of the "Name" property on the corresponding UserItem. Here's a more complicated query:
C#
LearningStoreQuery query = store.CreateQuery("UserItem");
query.AddColumn("Id");
query.AddColumn("Name");
query.AddCondition("Name", LearningStoreConditionOperator.LessThan, "Joe");
query.AddSort("Name", LearningStoreSortDirection.Ascending);
This query will return the Ids and names of all the users having a name less than "Joe." The DataTable will again contain one row for each UserItem. The DataTable will contain two columns. The first column will be named "Id" and will contain the Id of the corresponding UserItem. The second column will be named "Name" and will contain the Name of the corresponding UserItem. The users will be sorted in ascending order by their name.